package com.android.djlmapp.activity.my.zhaunchu;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.djlmapp.R;
import com.android.djlmapp.activity.my.FeedBackActivity;
import com.android.djlmapp.base.BaseActivity;
import com.android.djlmapp.tools.global.UserInfoUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ShiMingSucActivity extends BaseActivity {
    @BindView(R.id.ll_top_back)
    LinearLayout llTopBack;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.yrz)
    ImageView yrz;
    @BindView(R.id.tv_sm_name)
    TextView tvSmName;
    @BindView(R.id.tv_sm_num)
    TextView tvSmNum;
    @BindView(R.id.rl_bgrz)
    RelativeLayout rlBgrz;
    @BindView(R.id.home_iv_readpoint)
    ImageView homeIvReadpoint;
    @BindView(R.id.top_notes)
    ImageView topNotes;

    private String bd_name;
    private String bd_mobile;
    private String newName;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shi_ming_suc);
        ButterKnife.bind(this);
        initView();
        initData();
    }


    @Override
    protected void initView() {
        homeIvReadpoint.setVisibility(View.GONE);
        topNotes.setVisibility(View.GONE);
        tvName.setText("认证成功");
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onResume() {
        super.onResume();
        UserInfoUtils utils = UserInfoUtils.getUserInfoUtilsInstance();

        bd_name = utils.GetRelName();
        bd_mobile = utils.getMobile();

        if (bd_name != null && !TextUtils.isEmpty(bd_name)) {
            if (bd_name.length() == 1) {
                newName = bd_name;
            } else if (bd_name.length() == 2) {
                newName = bd_name.replace(bd_name.substring(0, bd_name.length() - 1), "*");// 隐藏用户信息
            } else if (bd_name.length() == 3) {
                newName = bd_name.replace(bd_name.substring(0, bd_name.length() - 2), "*");// 隐藏用户信息
            } else if (bd_name.length() == 4) {
                newName = bd_name.replace(bd_name.substring(0, bd_name.length() - 2), "**");// 隐藏用户信息
            } else {
                newName = bd_name.replace(bd_name.substring(1, bd_name.length() - 1), "***");// 隐藏用户信息
            }
        }


        tvSmName.setText(newName);
        // 身份证号中间数字星号显示
        String start = bd_mobile.substring(0, 3);
        String end = bd_mobile.substring(bd_mobile.length() - 4);
        tvSmNum.setText(start + "****" + end);
    }

    @OnClick({R.id.ll_top_back, R.id.yrz, R.id.rl_bgrz})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ll_top_back:
                finish();
                break;
            case R.id.yrz:
                break;
            case R.id.rl_bgrz:
                startActivity(new Intent(this, FeedBackActivity.class));
                break;
        }
    }
}
